using Zhaoxi.Zhihu.SharedKerel.Domain;

namespace Zhaoxi.Zhihu.SharedKerel.Repositoy;

public interface IRepository<T> : IReadRepository<T> where T : class, IEntity<int>, IAggregateRoot
{
    /// <summary>
    /// 在数据库中添加实体
    /// </summary>
    /// <param name="entity"></param>
    /// <returns></returns>
    T Add(T entity);

    /// <summary>
    /// 在数据库中更新实体
    /// </summary>
    /// <param name="entity"></param>
    void Update(T entity);

    void Delete(T entity);

    Task<int> SaveChangesAsync(CancellationToken cancellationToken);

}